Skip to content

[fix](aggregate) Fix nullable aggregate visitor dispatch#64885

Open
morrySnow wants to merge 1 commit into
apache:masterfrom
morrySnow:fix-bool-agg
Open

[fix](aggregate) Fix nullable aggregate visitor dispatch#64885
morrySnow wants to merge 1 commit into
apache:masterfrom
morrySnow:fix-bool-agg

Conversation

@morrySnow

@morrySnow morrySnow commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

related to #55643

Problem Summary: Bool aggregate functions such as bool_and, bool_or, and bool_xor extend NullableAggregateFunction, but their AggregateFunctionVisitor default methods delegated directly to visitAggregateFunction. This bypassed visitor implementations that specialize NullableAggregateFunction. Route these bool aggregate visitor methods through visitNullableAggregateFunction and add a unit test that verifies all current NullableAggregateFunction defaults dispatch to the nullable visitor path.

Release note

None

Check List (For Author)

  • Test: Unit Test
    • ./run-fe-ut.sh --run org.apache.doris.nereids.trees.expressions.visitor.AggregateFunctionVisitorTest
    • cd fe && mvn checkstyle:check -pl fe-core
  • Behavior changed: Yes. Nullable bool aggregate functions now use the NullableAggregateFunction visitor default path.
  • Does this need documentation: No

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Bool aggregate functions such as bool_and, bool_or, and bool_xor extend NullableAggregateFunction, but their AggregateFunctionVisitor default methods delegated directly to visitAggregateFunction. This bypassed visitor implementations that specialize NullableAggregateFunction. Route these bool aggregate visitor methods through visitNullableAggregateFunction and add a unit test that verifies all current NullableAggregateFunction defaults dispatch to the nullable visitor path.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.nereids.trees.expressions.visitor.AggregateFunctionVisitorTest
    - cd fe && mvn checkstyle:check -pl fe-core
- Behavior changed: Yes. Nullable bool aggregate functions now use the NullableAggregateFunction visitor default path.
- Does this need documentation: No
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@morrySnow

Copy link
Copy Markdown
Contributor Author

/review

@morrySnow

Copy link
Copy Markdown
Contributor Author

run buildall

@morrySnow morrySnow changed the title [fix](fe) Fix nullable aggregate visitor dispatch [fix](aggregate) Fix nullable aggregate visitor dispatch Jun 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the two-file PR for nullable aggregate visitor dispatch. I did not find a blocking issue or a valuable inline comment to add.

Critical checkpoint conclusions:

  • Goal/test: The change fixes BoolAnd, BoolOr, and BoolXor so their visitor defaults dispatch through visitNullableAggregateFunction; this matches their NullableAggregateFunction hierarchy and the AdjustAggregateNullableForEmptySet path that rewrites empty-group aggregate nullability. The added JUnit reflection test covers the current concrete nullable aggregate visitor methods, including ForEachCombinator.
  • Scope: The production change is small and focused: three default visitor dispatch calls plus one targeted test.
  • Parallel paths: I checked the remaining aggregate visitor defaults against the aggregate class hierarchy; the methods still dispatching to visitAggregateFunction correspond to non-nullable/base aggregate paths, while the current nullable aggregate subclasses are covered by nullable dispatch. A static comparison found no current nullable subclass missing from the new test list.
  • Concurrency/lifecycle/config/compatibility/transactions/storage/observability: Not applicable to this FE visitor-dispatch change; no new config, protocol, persisted state, locking, or runtime lifecycle behavior is introduced.
  • Test/style validation: git diff --check FETCH_HEAD..HEAD passed. I did not run FE unit tests because this checkout lacks thirdparty/installed and thirdparty/installed/bin/protoc, and FE AGENTS instructions require stopping before FE build/test when protoc is absent.

User focus: No additional user-provided focus was present.

Subagent conclusions: optimizer-rewrite and tests-session-config both reported no candidates in their initial passes. After the main ledger was updated with a no-inline-comment proposed final set, convergence round 1 ended with both subagents replying NO_NEW_VALUABLE_FINDINGS for the same current ledger/comment set.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29198 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 70b33d89e21872d79e9fea9cd06b169df5c09cee, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17703	4069	3975	3975
q2	2012	330	188	188
q3	10289	1508	869	869
q4	4680	472	345	345
q5	7543	866	594	594
q6	190	170	142	142
q7	803	843	620	620
q8	9334	1595	1638	1595
q9	5617	4543	4551	4543
q10	6749	1809	1536	1536
q11	426	275	250	250
q12	632	426	303	303
q13	18164	3399	2759	2759
q14	263	261	244	244
q15	q16	783	788	713	713
q17	958	896	1006	896
q18	6901	5923	5536	5536
q19	1216	1234	1061	1061
q20	471	402	271	271
q21	5505	2632	2454	2454
q22	445	359	304	304
Total cold run time: 100684 ms
Total hot run time: 29198 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4304	4253	4247	4247
q2	333	346	223	223
q3	4595	4993	4410	4410
q4	2111	2153	1407	1407
q5	4439	4334	4329	4329
q6	236	177	128	128
q7	1725	1639	1752	1639
q8	2687	2222	2173	2173
q9	8403	8381	8107	8107
q10	4836	4741	4318	4318
q11	585	426	376	376
q12	743	790	544	544
q13	3284	3628	2946	2946
q14	303	295	273	273
q15	q16	744	743	664	664
q17	1374	1339	1345	1339
q18	7984	7497	7340	7340
q19	1185	1168	1137	1137
q20	2232	2201	1947	1947
q21	5283	4601	4447	4447
q22	516	450	390	390
Total cold run time: 57902 ms
Total hot run time: 52384 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 172000 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 70b33d89e21872d79e9fea9cd06b169df5c09cee, data reload: false

query5	4339	643	478	478
query6	446	196	180	180
query7	4841	565	324	324
query8	335	187	173	173
query9	8768	4012	4012	4012
query10	469	314	271	271
query11	5912	2352	2142	2142
query12	157	100	101	100
query13	1264	615	413	413
query14	6272	5322	4971	4971
query14_1	4278	4279	4282	4279
query15	209	202	184	184
query16	1037	437	427	427
query17	917	701	573	573
query18	2424	470	331	331
query19	204	179	138	138
query20	107	107	107	107
query21	213	141	115	115
query22	13603	13610	13460	13460
query23	17435	16621	16094	16094
query23_1	16338	16247	16260	16247
query24	7592	1777	1276	1276
query24_1	1304	1308	1292	1292
query25	529	457	369	369
query26	1295	316	171	171
query27	2715	558	348	348
query28	4489	1986	2006	1986
query29	1051	619	470	470
query30	303	232	198	198
query31	1106	1065	934	934
query32	98	61	59	59
query33	519	302	249	249
query34	1208	1118	669	669
query35	778	783	677	677
query36	1405	1383	1187	1187
query37	157	107	90	90
query38	1909	1723	1625	1625
query39	921	923	898	898
query39_1	863	879	889	879
query40	225	128	107	107
query41	80	85	88	85
query42	95	90	90	90
query43	328	331	282	282
query44	1441	787	776	776
query45	207	185	179	179
query46	1104	1185	775	775
query47	2409	2292	2271	2271
query48	415	431	315	315
query49	588	422	333	333
query50	985	352	257	257
query51	4482	4448	4404	4404
query52	85	83	74	74
query53	245	266	198	198
query54	294	240	214	214
query55	75	72	67	67
query56	242	229	235	229
query57	1455	1419	1329	1329
query58	251	226	222	222
query59	1576	1634	1416	1416
query60	300	253	257	253
query61	178	171	176	171
query62	693	659	585	585
query63	235	193	193	193
query64	2540	818	692	692
query65	4847	4774	4746	4746
query66	1817	476	347	347
query67	28190	28821	28770	28770
query68	3354	1588	909	909
query69	412	302	269	269
query70	1089	971	938	938
query71	303	228	212	212
query72	2866	2590	2277	2277
query73	824	780	426	426
query74	5103	4964	4759	4759
query75	2586	2549	2156	2156
query76	2296	1184	776	776
query77	337	394	289	289
query78	12282	12434	11881	11881
query79	1425	1154	739	739
query80	1276	483	381	381
query81	525	276	231	231
query82	637	158	123	123
query83	356	265	252	252
query84	314	150	114	114
query85	913	545	430	430
query86	425	304	283	283
query87	1837	1860	1773	1773
query88	3697	2758	2745	2745
query89	428	385	329	329
query90	1924	181	183	181
query91	172	154	132	132
query92	65	64	56	56
query93	1599	1479	857	857
query94	711	354	281	281
query95	654	371	357	357
query96	1088	783	364	364
query97	2707	2706	2566	2566
query98	217	202	199	199
query99	1172	1147	1030	1030
Total cold run time: 257243 ms
Total hot run time: 172000 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.22 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 70b33d89e21872d79e9fea9cd06b169df5c09cee, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.25	0.13	0.14
query4	1.61	0.16	0.13
query5	0.27	0.22	0.22
query6	1.23	1.04	1.04
query7	0.04	0.01	0.01
query8	0.05	0.04	0.04
query9	0.37	0.31	0.31
query10	0.56	0.55	0.54
query11	0.18	0.13	0.14
query12	0.18	0.14	0.15
query13	0.47	0.46	0.47
query14	1.06	1.02	0.99
query15	0.61	0.61	0.60
query16	0.33	0.34	0.33
query17	1.12	1.09	1.08
query18	0.23	0.21	0.21
query19	2.02	2.00	1.98
query20	0.02	0.02	0.01
query21	15.43	0.22	0.13
query22	4.86	0.05	0.05
query23	16.13	0.30	0.12
query24	2.93	0.41	0.33
query25	0.11	0.05	0.04
query26	0.76	0.20	0.15
query27	0.04	0.04	0.04
query28	3.55	0.93	0.53
query29	12.51	4.19	3.47
query30	0.29	0.16	0.15
query31	2.76	0.58	0.31
query32	3.23	0.60	0.48
query33	3.28	3.20	3.18
query34	15.60	4.20	3.50
query35	3.55	3.53	3.54
query36	0.54	0.43	0.43
query37	0.10	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.04
query40	0.18	0.17	0.15
query41	0.09	0.04	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 96.81 s
Total hot run time: 25.22 s

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.0.x dev/4.1.x reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants